﻿using System;
using System.IO;

namespace StudentInfoManager
{
    class Program
    {
        static void Main(string[] args)
        {
            //string path = @"C:\file.txt";
            string filename = "students.txt";
            string folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string path = Path.Combine(folder, filename);

            Student[] students = ClassRoom.Deserialize(path);



            Console.Write("n = ");
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine("---------------");

            if (n < 0)
            {
                Console.WriteLine("Error: n < 1");
                return;
            }

            ClassRoom cr = new ClassRoom(students.Length + n);

            for (int i = 0; i < students.Length; i++)
            {
                Console.WriteLine(students[i].ToString());
                cr.Add(students[i]);
            }

            /*
            Student s1 = new Student();
            s1.Name = "Bob";
            s1.Email = "bob@gmail.com";

            Student s2 = new Student("Alice", "alice@yahoo.com");

            Student s3 = new Student("John Smith");
            s3.Email = "john.smith@microsoft.com";

            cr.Add(s1);
            cr.Add(s2);
            cr.Add(s3);
            */

            while (!cr.IsFull)
            {
                Student s = new Student();

                Console.Write("Name: ");
                s.Name = Console.ReadLine();

                Console.Write("Email: ");
                s.Email = Console.ReadLine();

                cr.Add(s);

                Console.WriteLine("-----------------");
            }

            ClassRoom.Serialize(path, cr.MailingList);

            Console.ReadKey();

        }
    }
}
